<template>
  <div>
    <div class="container">
      <div class="row">
        <div
          class="col-12 col-sm-9 col-md-7 col-lg-6 mx-auto pt-5"
          style="height: 500px"
        >
          <div class="card mt-5">
            <div class="card-header">
              <h3 class="text-center text-secondary">Vue商城后台管理系统</h3>
            </div>
            <div class="card-body">
              <el-form ref="form" :model="form" :rules="rules">
                <el-form-item prop="username">
                  <el-input
                    v-model="form.username"
                    size="medium"
                    placeholder="请输入用户名"
                  ></el-input>
                </el-form-item>
                <el-form-item prop="password">
                  <el-input
                    v-model="form.password"
                    size="medium"
                    placeholder="请输入密码"
                  ></el-input>
                </el-form-item>
                <el-form-item>
                  <el-button class="w-100" type="primary" size="medium"
                  @click="submit"
                    >立即登陆</el-button
                  >
                </el-form-item>
              </el-form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "login",
  data() {
    return {
      form: {
        username: "",
        password: "",
      },
      rules: {
        username: [
          { required: true, message: "请输入用户名", trigger: "blur" },
          {
            pattern: /^[a-zA-Z]{3,10}$/,
            message: "登陆名称不符合要求",
            trigger: "blur",
          },
        ],
        password: [
          { required: true, message: "请输入密码", trigger: "blur" },
          {
            pattern: /^[a-zA-Z0-9]{6,15}$/,
            message: "密码不符合要求",
            trigger: "blur",
          },
        ],
      },
    };
  },
  components: {},
  props: {},
  created() {},
  computed: {},
  watch: {},
  methods: {
      submit() {
          this.$refs.form.validate((valid) => {
              if(!valid) return
              this.$router.push('/index')
          })
      }
  },
};
</script>
<style lang="less" scoped>
</style>
